﻿@model IEnumerable<A_Shop.Models.Producto>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<table style="background-color:rgba(255, 255, 255, 0.78)" class="table table-bordered">
    <tr class="success">
         
        <th>
            @Html.DisplayNameFor(model => model.Nombre)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Modelo)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Marca)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Precio)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Descripcion)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Foto)
        </th>
       
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        
        <td>
             <a href="~/Cliente/Detalle/@item.id" target="_blank">
           @Html.DisplayFor(modelItem => item.Nombre)</a>
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Modelo)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Marca.Nombre)
            <img src=" @Html.DisplayFor(modelItem => item.Marca.Foto)" height="200" width="200" />
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Precio)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Descripcion)
        </td>
        <td>
               @if (item.Foto != null) {
                <img src="@Html.DisplayFor(modelItem => item.Foto)" height="150" width="150"/>
            } else {
                <img src="@Url.Content("~/Content/productos/"+ @item.id +".jpg")" height="150" width="150"/>
            }
        </td>
        
        <td>
            @Html.ActionLink("Editar", "Edit", new { id=item.id }) |
            @Html.ActionLink("Detalles", "Details", new { id=item.id }) |
            @Html.ActionLink("Detalles", "Details", new { id=item.id }) |
            <form action="~/Admin/Delete" method="get" name="id">
                <input type="hidden" value="@item.id" name="id" />
                <input type="submit" value="Eliminar" />
            </form>
        </td>
    </tr>
}

</table>
<p>
    @Html.ActionLink("Crear nuevo producto", "Create")
    </p>
<p>
    @Html.ActionLink("Crear nueva marca", "Create", "Marca")
    </p>
